package com.jeesite.modules.stock.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateFormat {

	public static Date parseDate(String dateStr) {
		SimpleDateFormat fr = new SimpleDateFormat("yyyy-MM-dd");
		try {
			return fr.parse(dateStr);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}

	public static String formatDate(Date date) {
		SimpleDateFormat fr = new SimpleDateFormat("yyyy-MM-dd");
		return fr.format(date);
	}

	public static Date dayPlus(Date date, int diff) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.DAY_OF_MONTH, diff);
		return calendar.getTime();
	}
}
